#include<string>
using namespace std;
class AddMinimum {
public:
    int addMinimum(string word) {
      int count = 3;
      int ret = 0;
      int left = 0;
      int right = 0;
      int len = word.size();
      while(right<len)
      {
          if(right+1 < len && (word[right+1]-word[left] == right+1-left))
          {
              if(right+2-left == count)
              {
                  left = right+2;
                  right = left;
              }
              right++;
          }
          else if(right+1 < len && (word[right+1]-word[left] == 2))
          {
              ret += 1;
              left = right + 2;
              right = left;
          }
          else
          {
              ret += count -(right - left +1);
              left = right+1;
              right = left;
          }
      }  
      return ret;
    }
};

//int main()
//{
//    AddMinimum a;
//    string word = "aaabca";
//    a.addMinimum(word);
//    return 0;
//}
